package com.xiaowen.codeDataRequest.controller;

import cn.hutool.core.util.ObjectUtil;
import com.xiaowen.codeDataRequest.entity.CodeDataRequestParam;
import com.xiaowen.codeDataRequest.service.CodeDataRequestParamService;
import com.xiaowen.tool.dto.Result;
import org.apache.commons.compress.utils.Lists;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author yf-wenhao
 * @since 2024-11-20
 */
@RestController
@RequestMapping("/codeDataRequest/codeDataRequestParam")
public class CodeDataRequestParamController {

    @Autowired
    private CodeDataRequestParamService codeDataRequestParamService;

    /**
     * 获取编码模板
     * @param projectId the id
     * @return the result
     * @author hero
     * @date 2024 -09-18 14:25:03
     */
    @GetMapping(value = "/list")
    public Result<List<CodeDataRequestParam>> listByProjectId(@RequestParam("projectId") Integer projectId) {
        if (ObjectUtil.isEmpty(projectId)){
            return new Result<List<CodeDataRequestParam>>().ok(Lists.newArrayList());
        }
        return new Result<List<CodeDataRequestParam>>().ok(codeDataRequestParamService.listByProjectId(projectId));
    }
}
